import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { ItemInfo } from "../../resource/info/ItemInfo";
import { ItemData } from "../../resource/info/ItemData";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { ColorConfig } from "../../resource/ColorConfig";
import { ResouceConst } from "../../../component/gconst/ResouceConst";
import { BaseItem } from "../common/BaseItem";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { GLabel } from "../../../../com/mui/controls/GLabel";
import { GNumericStepper } from "../../../../com/mui/controls/GNumericStepper";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { GButton } from "../../../../com/mui/controls/GButton";
import { Language } from "../../../../extend/language/Language";
import { GameRMI } from "../../net/rmi/GameRMI";
import { AMI_ITest_addItem } from "../../../../Message/Game/AMI_ITest_addItem";
import { ShopItemInfo } from "../../resource/info/ShopItemInfo";
type int = number;
//class FreeShopRender
    
    export  class FreeShopRender extends GCellRenderer
    {
        constructor()
        {
            super();
            this._oIngot = new Object /* flash.display.Bitmap */();
            this._pIngot = new Object /* flash.display.Bitmap */();
            this.createChildren();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            var loc1=super.data as ItemInfo;
            if (loc1) 
            {
                this._propItem.itemData = new ItemData(loc1.item.code);
                this._name.htmlText = HTMLUtil.addColor(loc1.item.name, ColorConfig.instance.getItemColor(loc1.item.color).color);
                this._code.text = "code:" + loc1.item.code.toString();
                this._oPriceNumLabel.text = loc1.item.sellPrice.toString();
            }
            return;
        }

        /* internal  */createChildren(): void
        {
            this._windowCenterB = ResouceConst.getScaleBitmap("WindowCenterB");
            this._windowCenterB.width = 200;
            this._windowCenterB.height = 82;
            this.addChild(this._windowCenterB);
            this._propItem = new BaseItem();
            this._propItem.isDragAble = false;
            ObjCreate.setObjAttri(this._propItem, 10, 12, 65, 65, this);
            this._labelBitmap = new Object /* flash.display.Bitmap */();
            this._labelBitmap.x = 5;
            this._labelBitmap.y = 7;
            this.addChild(this._labelBitmap);
            ObjCreate.createBg(80, 0, 110, 20, this, ImagesConst.SelectedBg);
            this._name = new GTextFiled();
            this._name.selectable = true;
            this._name.x = 80;
            this._name.y = 2;
            this.addChild(this._name);
            this._code = ObjCreate.createTextField("", 80, 28, 90, 20, this, GlobalStyle.textFormat5);
            this._code.selectable = true;
            this._oPriceNumLabel = new GLabel();
            this._oPriceNumLabel.width = 40;
            this._oPriceNumLabel.autoSize = flash.text.TextFieldAutoSize.RIGHT;
            this._oPriceNumLabel.x = 150;
            this._oPriceNumLabel.y = 20;
            this.addChild(this._oPriceNumLabel);
            this._oIngot = new Object /* flash.display.Bitmap */();
            this._oIngot.x = 170;
            this._oIngot.y = 20;
            this.addChild(this._oIngot);
            this._pIngot = new Object /* flash.display.Bitmap */();
            this._pIngot.x = 170;
            this._pIngot.y = 40;
            this.addChild(this._pIngot);
            this._numericStepper = new GNumericStepper();
            this._numericStepper.setSize(60, 22);
            this._numericStepper.move(80, 55);
            this._numericStepper.styleName = "NumericStepper";
            this._numericStepper.addEventListener(flash.events.Event.CHANGE, this.onBuyNumChange);
            this._numericStepper.drawNow();
            this._numericStepper.textField.setStyle("upSkin", GlobalClass.getScaleBitmap("WindowCenterB", new Object /* flash.geom.Rectangle */(4, 4, 36, 21)));
            this._numericStepper.textField.drawNow();
            this._numericStepper.maximum = 99;
            this._numericStepper.minimum = 1;
            this.addChild(this._numericStepper);
            this._buyBtn = new GButton();
            this._buyBtn.label = Language.getString(53021);
            this._buyBtn.styleName = "Button";
            this._buyBtn.setSize(50, 24);
            this._buyBtn.move(145, 55);
            this._buyBtn.drawNow();
            this._buyBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBuyBtnClickhandler);
            this.addChild(this._buyBtn);
            return;
        }

        /* internal  */onBuyNumChange(arg1: Object /* flash.events.Event */): void
        {
            return;
        }

        protected onBuyBtnClickhandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=this._numericStepper.value;
            var loc2=data as ItemInfo;
            GameRMI.instance.iTestPrxHelper.addItem_async(new AMI_ITest_addItem(), loc2.item.code, loc1);
            return;
        }

        protected /* override */ draw(): void
        {
            super.draw();
            this.mouseChildren = true;
            this.mouseEnabled = true;
            return;
        }

        /* internal */ /* var */_name: GTextFiled;

        /* internal */ /* var */_code: GTextFiled;

        /* internal */ /* var */_propItem: BaseItem;

        /* internal */ /* var */_oPriceNumLabel: GLabel;

        /* internal */ /* var */_oIngot: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_pIngot: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_buyBtn: GButton;

        /* internal */ /* var */_windowCenterB: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_labelBitmap: Object /* flash.display.Bitmap */;

        protected /* var */_numericStepper: GNumericStepper;

        /* internal */ /* var */_priceType: int;

        /* internal */ /* var */_priceImgName: string;

        protected /* var */shopItemInfo: ShopItemInfo;

        public static /* var */isWider: Boolean=false;
    }

            FreeShopRender.isWider = false;
        